package com.hsgene.order.constants.v1;

/**
 * @Description: 订单套餐状态枚举
 * @ProjectName: hdas-geneshop
 * @Package: com.hsgene.order.constants.v1
 * @Author: 江承良
 * @CreateDate: 2018/11/8 16:10
 * @Version: 1.0
 * Copyright: Copyright (c) 2018
 */
public enum OrderPackageStatus {
    /**
     * 订单套餐状态枚举
     */
    NONE_BEGIN(0, "未开始"),
    SAMPLE_CONFIRM(1, "样本待确认"),
    REPORT_UPLOAD(2, "报告待上传"),
    REPORT_CHECK(3, "报告待审核"),
    PENDING_DELIVERY(4, "待寄送"),
    PENDING_SIGN(5, "待签收"),
    FINISH(6, "完成"),
    WAIT_CONFIRM(7, "变更待确认"),
    END(8, "终止");
    private int code;

    private String desc;

    OrderPackageStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String desc(int code) {
        for (OrderPackageStatus orderPackageStatus : values()) {
            if (code == orderPackageStatus.getCode()) {
                return orderPackageStatus.getDesc();
            }
        }
        return "未定义的状态";
    }

    public static OrderPackageStatus getEnum(Integer code) {
        if (code == null || code == 0) {
            return NONE_BEGIN;
        }
        for (OrderPackageStatus status : values()) {
            if (code == status.getCode()) {
                return status;
            }
        }
        throw new IllegalStateException("非法的订单套餐状态枚举code：" + code);
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
